home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-25 | 6.6 KB | 258 lines | [TEXT/MACA] |
- 6000 value maxTraps
-
- string trapName
- string buf
- string temp
- string buildStr
- 0 value names
- sarray inLines
- \ new: Names
- new: inLines
- new: buildStr
-
- new: trapName 100 setsize: trapName lock: trapName
- new: buf
- new: temp
-
- sarray debugStr
- new: debugStr
- true value debug?
- true value osErrs?
-
- maxTraps heap> ordered-col -> names
-
- \ parse the instructions after 'INLINE'. parse for , until reach a ;
- : inLineParse { addr0 \ addr char end -- addr addr' len } \ addr left =0 if end
- false -> end
- addr0 -> addr
- BEGIN addr c@ -> char
- char ascii , =
- char ascii ; = dup IF true -> end THEN or not
- WHILE 1 ++> addr
- REPEAT
- end IF 0 ELSE addr 1+ THEN addr0 addr addr0 - ;
-
- \ find Functions or Procedures
- : funprocParse { addr0 \ addr char len -- addr' len } \ addr left =0 if end
- addr0 -> addr
- BEGIN addr c@ -> char
- char ascii 0 >=
- WHILE 1 ++> addr
- REPEAT
- addr addr0 - -> len
- addr0 len + 1- c@ ascii : =
- IF -1 ++> len THEN
- addr0 len ;
-
- : readfile ( -- ) \ unlock: buf
- new: loadfile TXTYPE 1 stdget: topfile
- IF open: topfile abort" can't open"
- topfile size: topfile read: buf drop
- THEN remove: loadfile
- start: buf ;
-
- : (findThem) { addr len \ flag -- b } \ b=true ok, false nomore finds
- 0 -> flag
- BEGIN
- addr len indexof: buf
- IF ptr: buf + dup 1- c@ 13 =
- IF bl parse 2drop funprocParse put: trapName uc: trapName 2drop
- true true -> flag
- ELSE drop 1 offset: buf false
- THEN
- ELSE true false -> flag
- THEN
- UNTIL flag ;
-
- \ Find 'FUNCTION' or 'PROCEDURE' that begins a new line, then search for the
- \ word 'INLINE'. Then get the code string, parsing for commas and ending with semi
- \ colon.
-
- : FindFunction " FUNCTION" (findThem) ;
- : FindProcedure " PROCEDURE" (findThem) ;
-
- : findINLINE { \ addr where -- b } clear: buildStr
- 13 charof: buf drop -> where 1 offset: buf
- 13 charof: buf 2drop 1 offset: buf
- ptr: buf where: buf + 13 parse put: temp drop
- start: temp
- " INLINE" indexof: temp
- IF lock: temp ptr: temp + ascii $ parse 2drop -> addr
- BEGIN addr inLineParse add: buildStr -> addr
- lock: buildStr
- start: buildStr ascii $ charof: buildStr
- IF drop bl 1 substr: buildStr drop c! THEN
- unlock: buildStr bl +: buildStr
- addr 0=
- UNTIL unlock: temp
- oserrs? IF size: buildStr 6 - 0 max moveto: buildStr
- " 3E80" indexOf: buildStr
- IF drop 4 substr: buildStr " 2F00" replace: buildStr THEN
- THEN
- true
- ELSE print: trapName ." INLINE not found" cr
- where moveto: buf false
- THEN ;
-
- : endSpace ( addr -- addr) dup c@ bl = IF 1+ endSpace THEN ;
-
- hex
- \ ( str255addr -- hashVal ) hash a name into a 32-bit word
- create HashName
- 2057 w, \ move.l (sp),a0
- d1cb w, \ adda.l a3,a0
- 7000 w, \ moveq #0,d0 \ Result will go to D0
- 7400 w, \ moveq #0,d2
- 1418 w, \ move.b (a0)+,d2 \ Count
- c43c007f , \ and.b #127,d2 \ Clear top bit in case it's a name field
- 60000008 , \ bra lptest
- ef98 w, \ loop rol.l #7,d0
- 1218 w, \ move.b (a0)+,d1
- b300 w, \ eor.b d1,d0 \ b300
- 51cafff8 , \ lptest dbra d2,loop
- 08c0001f , \ bset #31,d0
- 2e80 w, \ move.l d0,(sp)
- next,
- decimal
-
- \ 0 value addr
- \ 0 value trap#
- \ 0 value nhash
- \ 0 value endAddr
-
- : MakeTool { \ addr trap# nhash endAddr -- }
- get: trapName
- str255 -base -> addr
- addr HashName -> nhash
- nhash indexOf: names ( trap# hashval [idx] bool )
- IF print: trapName ." collision" . cr exit \ mark collision item
- ELSE nhash add: names
- THEN
- lock: buildStr get: buildStr + 1- -> endAddr
- ptr: buildStr -> Addr
- clear: temp hex
- BEGIN addr endAddr <
- WHILE 0.. addr endspace 1- (number) -> addr drop pad w! pad 2 add: temp ?pause
- REPEAT decimal
- lock: temp get: temp add: inlines
- debug? IF temp =: trapName 9 +: temp get: buildStr add: temp get: temp add: debugStr THEN
- unlock: temp unlock: buildStr ;
-
- : doit readfile size: buf
- IF start: buf lock: buf
- BEGIN findFunction
- WHILE findInLine IF MakeTool THEN
- REPEAT
- start: buf
- BEGIN findProcedure
- WHILE findInLine IF MakeTool THEN
- REPEAT
- THEN
- unlock: buf clear: buf ;
-
-
- \ get info for default vol - leave vol name at pad
- : volinfo { -- fcode }
- 0 ffcb 22 + w!
- 0 ffcb 28 + w!
- HFS? IF
- 9 ffcb +base dirfind
- ELSE ffcb fcall pbgetvinfo
- then ;
- \ ( -- #files )
- : filecount volinfo drop
- HFS? IF ffcb 52 + w@
- ELSE ffcb 40 + w@
- THEN ;
-
- \ ( file# -- b ) leave name of file at pad
- : Getidxfile { \ dirid -- }
- fFcb 28 + w! \ set file index
- pad +base fFcb 18 + ! \ filename addr
- pad 64 blanks getdirid: ffcb -> dirid
- fFcb fcall PBHGetFInfo
- 0= IF true ELSE false THEN
- dirid setdirid: ffcb
- 13 pad count + 1+ c! ;
-
-
- : uhuh ." reading: " print: topfile cr
- topfile size: topfile read: buf drop
- size: buf
- IF start: buf lock: buf
- BEGIN findFunction
- WHILE findInLine IF MakeTool THEN
- REPEAT
- start: buf
- BEGIN findProcedure
- WHILE findInLine IF MakeTool THEN
- REPEAT
- THEN
- unlock: buf clear: buf ;
-
- \ This is the word to execute, making sure the pathList is setup using the 'cl'
- \ word below. Will search through all text files
- : (setup) { \ gcurs dirid -- }
- watchcurs
- curs -> gcurs -curs \ Preserve cursor status
- clear: Names clear: inlines clear: debugstr
- unlock: inlines unlock: debugstr unlock: buf
- new: loadFile
- limit: path 0
- DO path IF i at: path name: fFcb i at: path swap drop ELSE clear: fFcb true THEN
- IF Filecount 1+ 1
- DO i getidxfile
- IF pad count name: topFile
- getdirid: ffcb setdirid: topfile
- openReadOnly: topFile ?error 132
- GetFileInfo: topFile drop
- GetType: topFile txType =
- IF
- uhuh
- THEN
- close: topFile drop
- THEN
- LOOP
- THEN
- LOOP
- gcurs -> curs \ Restore cursor status
- remove: loadFile
- arrowcurs ;
-
- : cl clear: path
- " :::universal interfaces:" add: path ;
-
- cl
-
- : saveNames new: loadfile
- " trapHash" name: topfile
- create: topfile drop
- size: names sp@ 4 write: topfile abort" 1 write error" drop
- names length: names write: topfile drop
- 'type BIN savesig set: topfile
- close: topfile drop
- " InLines" name: topfile
- create: topfile drop
- limit: inlines sp@ 4 write: topfile 2drop
- lock: inlines get: inlines write: topfile abort" 2 write error"
- 'type BIN savesig set: topfile
- remove: loadfile ;
-
- \ debugging
-
- \ : jj
- \ clear: inlines clear: names clear: debugstr
- \ size: buf
- \ IF start: buf lock: buf
- \ BEGIN findFunction dup IF ." fn=" print: trapname size: buildStr . ELSE ." noFun=" size: buildStr . THEN
- \ WHILE findInLine IF ." preParm=" size: buildStr . MakeTool ELSE ." noparm" size: buildStr . THEN cr
- \ REPEAT
- \ start: buf
- \ BEGIN findProcedure
- \ WHILE findInLine IF MakeTool THEN
- \ REPEAT
- \ THEN ;
-
- \ : uu start: buf clear: inlines clear: names clear: debugstr ;
- \ : yy findFunction IF 1 . findinline IF 2 . maketool THEN THEN print: trapname ;
-